
import 'package:flutter/material.dart';
import 'package:flutter_ahj_app/base/utils/StringUtils.dart';
import 'package:flutter_ahj_app/base/values/SQColor.dart';
import 'package:flutter_ahj_app/base/values/dimens.dart';
import 'package:flutter_ahj_app/app/yhpc/yhdj/ChoosePersonDan.dart';


typedef void DismissView();
typedef void ClickCallback(String id,String name);

class CustomSelectSbView extends StatefulWidget {

  ClickCallback   callBack;
  String wgName,wgNameid;
  String titleName;
  BuildContext mcontext;
  CustomSelectSbView({this.callBack,this.wgName,this.wgNameid, this.mcontext});
  @override
  _CustomSelectShenHeRenViewState createState() => _CustomSelectShenHeRenViewState();
}

class _CustomSelectShenHeRenViewState extends State<CustomSelectSbView> {


  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }
  Map map={};
  @override
  Widget build(BuildContext context) {
    return new Container(
      margin: EdgeInsets.fromLTRB(16, 16, 16, 16),
      child: new GestureDetector(
        onTap: (){
          Navigator.pop(context);
          Navigator.pushNamed(widget.mcontext, '/ChoosePersonDan',
              arguments: '')
              .then((value) {
            if (value != null) {
              Map map = value;
              if (value != null) {
                widget.wgName=map['name'];
                widget.wgNameid=map['openId'].toString();
                widget.callBack(widget.wgNameid,widget.wgName);
              }
            }
          });
        },
        child:  new DropdownButtonFormField(
          items: null,
          hint:  ( widget.wgNameid==null|| widget.wgNameid=="")?new Text(widget.titleName??"请选择确认人*"):
          new Text(StringUtils.getStr( widget.wgName),style: new TextStyle(color: SQColor.black_333333),),
          value:  ( widget.wgNameid==null|| widget.wgNameid=="")?"":
          new Text(StringUtils.getStr( widget.wgName),style: new TextStyle(color: SQColor.black_333333),),//下拉菜单选择完之后显示给用户的值
          decoration:
          InputDecoration(
            contentPadding: EdgeInsets.only(left:Dimens.dimens16,right:Dimens.dimens16),
            labelText:  widget.wgNameid==null?"":widget.titleName??"确认人*",
            labelStyle: TextStyle(color: SQColor.per87Black),
            border: OutlineInputBorder(
              borderRadius: BorderRadius.all(Radius.circular(Dimens.dimens4)),
            ),
          ),
        ),
      ),
    );
  }

}


